Repository navigation
Reimplement UnitsState::prepareProjectileTarget at 100%, from gynt's text on main (one header line each in two files) - #540
Open
kotijekriv wants to merge 2 commits into
Conversation
prepareProjectileTarget 0x0053CBD0 is `void`: the header has `int`, from Ghidra. The original leaves something different in eax on each path: the unit type less 22 (the switch index, 0x0053CDD3), a quotient, the 16-bit value it just stored. None of the seventeen calls on main reads a result, and the code matches with `void` only (the next commit): with `int`, the values have to be named and held, and scatter and the random number swap registers (85.7% / 79.2%). UnitsState.hpp and UnitsState.func.hpp, one line each. The declaration in UnitsState.hpp also names the third parameter leadDistanceUnk, as the definition does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UnitsState::prepareProjectileTarget from 85.7% / 79.2% (gynt's text, on main since sourcehold#238) to 100%. With the function `void` (the commit before), the returned values go (quick_diff 0.8566 -> 0.9928). The random adjustment of the target's height is written on the field itself, `+=` / `-=` in two arms, instead of through an unsigned copy (1.0000), and the three kinds of scatter are one if / else-if chain (the same listing). The random numbers that fed the returned quotients are passed straight on, the copy of the target's fixedRng is an int, and _scatter and _adjustment start at 0 (the same object code). _archerScatter is never read but stays: without it the archer cases go and both jump tables start at the catapult (quick_diff 0.9857). The target's position is stored in both arms, as before: once above the if reads 0.9162. The order of the tests and every constant are gynt's (e595955 81.5%, 0c20880 85.75%). Measured with real builds of this branch's tree on main 4591b6f (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised): 100.0 / 100.0 in a small build with OPENSHC_FUNCTION_VISIBILITY_UNITS off, in one with it on, and in a full build with it off (of this branch merged with the one for six other UnitsState functions). Passing the random numbers straight on, the int copy of fixedRng, the first values of _scatter and _adjustment and the two comments came after those builds. A small build with it off of the final text (this branch merged with the one for six other UnitsState functions, 550 files, 560 functions) reads every function as the earlier small build with it off did. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UnitsState::prepareProjectileTarget(0x0053CBD0) from 85.7% / 79.2% (reccmp raw / normalised; gynt's text, on main since #238) to 100.0% / 100.0%, withOPENSHC_FUNCTION_VISIBILITY_UNITSoff and on.Header change
int prepareProjectileTarget(...)becomesvoidinUnitsState.hppandUnitsState.func.hpp(a commit of its own). InUnitsState.hppthe same line also names the third parameterleadDistanceUnk, as the definition does. Main's declaration check fails and labels this PR until main has the two lines.voidonly. Withintthe leftover values have to be named and returned, and the scatter and the random number swap registers.What matched it
void: the returned values go, and with them the comment that they mean nothing (quick_diff0.8566 -> 0.9928).+=/-=in two arms, instead of through an unsigned copy (1.0000).Kept as it is
todo:fixme:ucp:note about targets with a negative height._archerScatteris never read, but its stores keep the archers' entries in both jump tables. Without them both tables start at the catapult (0.9857 inquick_diff).ifgive 0.9162.Measured
Setup: the bundled MSVC1400-SP1 against the Steam
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. All builds of this branch were made on main 4591b6f. It is cut from main 0cea04d, which adds six status lines (#538) and a tools script: nothing that is compiled.calculatePathKeepAndWallsGatesNotAllowed.cpp, which the list took in as a callee of main'sgiveMoveCommand. The list is every/GLfile of main, every.cppthat readsUnit::disappearFadeAlphaCountdown, the units of Reimplement UpdateCamel, UpdateLady, UpdateMother and UpdateFireEater from gynt's units branch, under /GL (100%) #515, Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516, Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) #518, Reimplement UpdatePeasant and UpdateMiller from gynt's units branch, under /GL (100%) #533 and Reimplement UpdateShield, UpdateHunter, UpdateAppleFarmer, UpdateJester and UpdateSlave from gynt's units branch (100%, three with OPENSHC_FUNCTION_VISIBILITY_UNITS on) #537, every caller of this function and the other changed UnitsState functions with their callee closures, every file of a function-visibility group that touches them): BUILD_OK and 0 failures in both. It reads 100.0% / 100.0% in both; every other function reads as in the same build of main but two.UpdateCatapultBuildingreads 100.0% / 100.0% with the option off and 99.6% / 95.5% with it on, where main reads 99.6% / 95.7% off and 100.0% / 100.0% on: its code is unchanged, a tie that goes either way with the layout.triggerDesyncIfTileUnitLinkageInvalidreads 100.0% / 100.0% in both, main 97.2% / 100.0%: the raw number only, from a name.UnitsStatefunctions andselectWorkerSpeechOrMoraleStateID(every.cppbut the three that don't compile: 3,041 files, 3,059 functions; BUILD_OK, 0 failures), against the full build of main's tree made for Reimplement UpdateShield, UpdateHunter, UpdateAppleFarmer, UpdateJester and UpdateSlave from gynt's units branch (100%, three with OPENSHC_FUNCTION_VISIBILITY_UNITS on) #537: the only functions that read differently are this one, those six andselectWorkerSpeechOrMoraleStateID(up to 100.0%), andConstructor_MenuandhandleMenuItems(98.4% and 97.9% there, 100.0% here: the known 0x11000000 flip with the image layout, their code unchanged). Nothing reads lower; the eleven/GLcallers keep their readings.fixedRnganint, gave_scatterand_adjustmenta first value, changed two comments and the parameter's name in the header. The final heads of this branch and the one for the six other functions, merged, were built again (small, option off, the same 550 files, 560 functions; BUILD_OK, 0 failures): every function reads as in the small builds with the option off above.Other PRs
#539 is ours and open: the six other
UnitsStatefunctions of the same round, whose full and final small builds above were made together with this branch. It shares only the status file with this one, in other lines.#536 is ours and open; it shares only the status file with this one, in other lines, and calls
prepareProjectileTargetnowhere.🤖 Generated with Claude Code